/*
ID: guoxu1
PROG: ride
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

#define cin fin
#define cout fout

inline int num( char c )
{
	return c - 'A' + 1;
}

int main()
{
	ifstream fin( "ride.in" );
	ofstream fout( "ride.out" );

	string a;
	getline( cin, a );
	string b;
	getline( cin, b );

	int produce1 = 1;
	for( size_t i = 0; i < a.size(); i++ )
	{
		produce1 *= num( a[i] );
	}
	
	int produce2 = 1;
	for( size_t i = 0; i < b.size(); i++ )
	{
		produce2 *= num( b[i] );
	}

	if( produce1 % 47 == produce2 % 47 )
	{
		cout << "GO" << endl;
	}
	else
	{
		cout << "STAY" << endl;
	}
	return 0;
}
